package simorg.security;

import simorg.domain.Role;
import simorg.domain.User;
import simorg.view.SessionAttribute;
import simorg.view.WebSessionContext;

public class AdminAccess implements SecurityAccess {

	User loggedInUser;
	
	public AdminAccess (WebSessionContext wc) {
		try {
			this.loggedInUser = (User) wc.getSessionAttribute(SessionAttribute.User);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	
	public boolean isAccessible() {
		if (this.loggedInUser == null ) return false;
		return Role.Admin.equals(this.loggedInUser.getRole());
	}

}
